<!DOCTYPE HTML>
<html>

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="HandheldFriendly" content="true" />
		<meta name="MobileOptimized" content="320" />
		<title>扫一扫</title>
		<script src="../js/mui.min.js"></script>
		<script src="../script/config.js"></script>
		<script type="text/javascript" src="../js/DMobileFrame_DownLoadUtil.js"></script>
		<script type="text/javascript" src="../js/common.js"></script>
		<script type="text/javascript">
			var localStorageManagers = require("script/localStorageManagers.js");
			//mui初始化
			mui.init();
			//plus初始化
			mui.plusReady(plusReady);
			//plusReady
			function plusReady() {}
			//扫码后处理
			function newscaned(t, result, f) {
				//添加课程
				if (result.indexOf('type=1') >= 0) {
					//判断课程状态
					var courseid = result.substring(result.indexOf("courseid=") + 9, result.length);
					var userid = localStorageManagers.getUseridSession();
					var url = serverAjax + 'mobile/course/getCourseStatus.do';
					mui.ajax(url, {
						data: {
							userid: userid,
							courseid: courseid
						},
						type: 'post',
						dataType: 'json',
						success: function(data) {
							var type = 0;
							if (data == 1) {
								mui.toast('没有找到该课程');
							} else if (data == 2) {
								mui.toast('您所在的学校还没有购买该课程');
							} else if (data == 3) {
								type = 2;
							} else if (data == 4) {
								type = 1;
							}
							if (type > 0) {
								mui.openWindow({
									url: '../selfcenter/selfstudycourse/selfcoursecatalog.html',
									id: 'selfcenter/selfstudycourse/selfcoursecatalog',
									extras: {
										'courseid': courseid,
										'type': type
									}
								});
							}
						},
						error: function(e1, e2, e3) {
							console.log(e1);
						}
					});
				}
			}
		</script>
		<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
		<style type="text/css" media="screen">
			.hdata {
				color: #e1673e;
				font-size: 14px;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}
			
			.button {
				background-color: #3ac9af;
				border-color: #3ac9af;
				margin-top: 100px;
			}
		</style>
	</head>

	<body onload="img=document.getElementById('bimg');">
		<div id="dcontent" class="dcontent">
			<br/>
			<img style="width:40%" id="bimg" src="../img/barcode.png" />
			<br/>
			<div class="button" onclick="clicked('barcode_scan.html',true,true);">扫一扫</div>
			<br/>
			<!--
			<ul id="history" class="dlist" style="text-align:left;">
				<li id="nohistory" class="ditem" onclick="onempty();">无历史记录	</li>
			</ul>
			<br/>
			<div class="button button-waring" onclick="cleanHistroy();">清空历史记录</div>
			 -->
		</div>
	</body>
	<script type="text/javascript" src="../js/immersed.js"></script>

</html>